package com.atguigu.servlet;

import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

public class Servlet07ServletContextWrite extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext servletContext = getServletContext();

        // 把数据存入应用域
        servletContext.setAttribute("attrNameApp", "黑神话悟空8月20日正式上线");

        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().write("已写入");
    }
}
